// ============================================================================
// System Management Module Styles
// - User management, role management, permission management styles
// - Role selection, form dialogs, data tables
// ============================================================================

// ------------------------------
// Role Selection Component
// ------------------------------

.role-selection {
  .role-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .role-item {
    padding: 8px;
    border: 1px solid var(--el-border-color);
    border-radius: var(--border-radius-base);
    transition: all 0.3s ease;

    &:hover {
      border-color: var(--el-color-primary);
      background-color: var(--el-color-primary-light-9);
    }
  }

  .role-checkbox {
    width: 100%;
    margin: 0;

    :deep(.el-checkbox__label) {
      width: 100%;
      padding-left: 8px;
    }
  }

  .role-info {
    .role-name {
      font-weight: 500;
      color: var(--el-text-color-primary);
      margin-bottom: 4px;
    }

    .role-description {
      font-size: 12px;
      color: var(--el-text-color-secondary);
      line-height: 1.4;
    }
  }

  .selected-roles {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
}

// ------------------------------
// Role Tags Display
// ------------------------------

.role-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;

  .el-tag {
    margin: 0;
    font-size: 12px;
  }
}

// ------------------------------
// User Management Styles
// ------------------------------

.user-management {
  .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-base);
    
    &.avatar-large {
      width: 48px;
      height: 48px;
    }
  }

  .user-info {
    .username {
      font-weight: 500;
      color: var(--el-text-color-primary);
    }

    .user-email {
      font-size: 12px;
      color: var(--el-text-color-secondary);
    }
  }

  .status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--border-radius-base);
    font-size: 12px;
    font-weight: 500;

    &.status-active {
      color: var(--el-color-success);
      background-color: var(--el-color-success-light-9);
    }

    &.status-inactive {
      color: var(--el-color-info);
      background-color: var(--el-color-info-light-9);
    }

    &.status-disabled {
      color: var(--el-color-danger);
      background-color: var(--el-color-danger-light-9);
    }
  }
}

// ------------------------------
// Permission Management Styles
// ------------------------------

.permission-management {
  .permission-tree {
    .custom-tree-node {
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-size: 14px;
      padding-right: 8px;

      .node-label {
        flex: 1;
        min-width: 0;
      }

      .node-actions {
        display: flex;
        gap: 8px;
      }
    }
  }

  .permission-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;

    .permission-card {
      padding: 12px;
      border: 1px solid var(--el-border-color-light);
      border-radius: var(--border-radius-base);
      cursor: pointer;
      transition: all 0.3s ease;

      &:hover {
        border-color: var(--el-color-primary);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
      }

      &.selected {
        border-color: var(--el-color-primary);
        background-color: var(--el-color-primary-light-9);
      }

      .permission-name {
        font-weight: 500;
        color: var(--el-text-color-primary);
        margin-bottom: 4px;
      }

      .permission-desc {
        font-size: 12px;
        color: var(--el-text-color-secondary);
      }
    }
  }
}

// ------------------------------
// Menu Management Styles
// ------------------------------

.menu-management {
  .menu-tree-container {
    border: 1px solid var(--el-border-color-light);
    border-radius: var(--border-radius-base);
    padding: 16px;
    background: var(--el-bg-color);

    .el-tree {
      background: transparent;
    }
  }

  .menu-node {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;

    .menu-icon {
      width: 16px;
      height: 16px;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .menu-title {
      flex: 1;
      font-size: 14px;
    }

    .menu-type {
      font-size: 12px;
      padding: 2px 6px;
      border-radius: 4px;
      
      &.type-menu {
        background: var(--el-color-primary-light-9);
        color: var(--el-color-primary);
      }

      &.type-button {
        background: var(--el-color-success-light-9);
        color: var(--el-color-success);
      }
    }

    .menu-actions {
      display: flex;
      gap: 4px;
      opacity: 0;
      transition: opacity 0.3s ease;
    }

    &:hover .menu-actions {
      opacity: 1;
    }
  }
}

// ------------------------------
// Form Dialog Styles
// ------------------------------

.system-form-dialog {
  .dialog-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;

    .header-icon {
      color: var(--el-color-primary);
    }

    .header-title {
      font-size: 16px;
      font-weight: 500;
      color: var(--el-text-color-primary);
    }
  }

  .form-section {
    margin-bottom: 24px;

    .section-title {
      font-size: 14px;
      font-weight: 500;
      color: var(--el-text-color-primary);
      margin-bottom: 12px;
      padding-bottom: 8px;
      border-bottom: 1px solid var(--el-border-color-lighter);
    }
  }

  .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;

    @media (max-width: 768px) {
      grid-template-columns: 1fr;
    }
  }

  .dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--el-border-color-lighter);
  }
}

// ------------------------------
// Data Table Enhancements
// ------------------------------

.system-data-table {
  .table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 16px;

    .toolbar-left {
      flex: 1;
      display: flex;
      align-items: center;
      gap: 12px;
    }

    .toolbar-right {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    @media (max-width: 768px) {
      flex-direction: column;
      align-items: stretch;

      .toolbar-left,
      .toolbar-right {
        justify-content: center;
      }
    }
  }

  .batch-operations {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--el-color-primary-light-9);
    border: 1px solid var(--el-color-primary-light-7);
    border-radius: var(--border-radius-base);
    margin-bottom: 16px;

    .batch-info {
      font-size: 14px;
      color: var(--el-text-color-regular);

      strong {
        color: var(--el-color-primary);
      }
    }

    .batch-actions {
      display: flex;
      gap: 8px;
    }
  }

  .table-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;

    .el-button {
      margin: 0;
      padding: 4px 8px;
      font-size: 12px;
    }
  }
}

// ------------------------------
// Search and Filter Styles
// ------------------------------

.search-filters {
  background: var(--el-bg-color);
  border: 1px solid var(--el-border-color-light);
  border-radius: var(--border-radius-base);
  padding: 16px;
  margin-bottom: 16px;

  .filter-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;

    &:last-child {
      margin-bottom: 0;
    }

    @media (max-width: 768px) {
      flex-direction: column;
      align-items: stretch;
      gap: 8px;
    }
  }

  .filter-group {
    display: flex;
    align-items: center;
    gap: 8px;

    .filter-label {
      font-size: 14px;
      color: var(--el-text-color-regular);
      white-space: nowrap;
      min-width: 60px;
    }
  }

  .search-actions {
    display: flex;
    gap: 8px;

    @media (max-width: 768px) {
      justify-content: center;
    }
  }
}

// ------------------------------
// Statistics Cards
// ------------------------------

.system-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;

  .stat-card {
    background: var(--el-bg-color);
    border: 1px solid var(--el-border-color-light);
    border-radius: var(--border-radius-large);
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;

    &:hover {
      transform: translateY(-2px);
      box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    }

    .stat-value {
      font-size: 28px;
      font-weight: 700;
      color: var(--el-color-primary);
      margin-bottom: 8px;
    }

    .stat-label {
      font-size: 14px;
      color: var(--el-text-color-secondary);
    }

    .stat-icon {
      font-size: 32px;
      color: var(--el-color-primary);
      margin-bottom: 12px;
    }

    // 不同类型的统计卡片
    &.stat-users .stat-value,
    &.stat-users .stat-icon {
      color: var(--el-color-primary);
    }

    &.stat-roles .stat-value,
    &.stat-roles .stat-icon {
      color: var(--el-color-success);
    }

    &.stat-permissions .stat-value,
    &.stat-permissions .stat-icon {
      color: var(--el-color-warning);
    }

    &.stat-online .stat-value,
    &.stat-online .stat-icon {
      color: var(--el-color-info);
    }
  }
}

// ------------------------------
// Responsive Design
// ------------------------------

@media (max-width: 768px) {
  .role-selection {
    .role-checkbox-group {
      gap: 6px;
    }

    .role-item {
      padding: 6px;
    }
  }

  .system-stats {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;

    .stat-card {
      padding: 16px;

      .stat-value {
        font-size: 24px;
      }

      .stat-icon {
        font-size: 28px;
      }
    }
  }

  .permission-management .permission-grid {
    grid-template-columns: 1fr;
  }
}

// ------------------------------
// Print Styles
// ------------------------------

@media print {
  .system-data-table {
    .table-toolbar,
    .batch-operations,
    .table-actions {
      display: none !important;
    }
  }

  .search-filters {
    display: none !important;
  }

  .system-stats .stat-card {
    break-inside: avoid;
  }
}
